package com.wen.web;

import android.app.Activity;
import android.webkit.JavascriptInterface;

import com.wen.web.event.JSEvent;


/**
 * WebView和JS的交互
 */

public class WebJSInterface {
    private final Activity mActivity;

    private WebJSInterface(Activity activity) {
        this.mActivity = activity;
    }

    static WebJSInterface create(Activity activity) {
        return new WebJSInterface(activity);
    }

    @SuppressWarnings("unused")
    @JavascriptInterface
    public String execute(String params) {
        if (mActivity != null) {
            final JSEvent event = new JSEvent(mActivity);
            return event.execute(params);
        }
        return null;
    }
}
